package org.ceva.training.service;

import java.util.Date;
import java.util.List;

import org.ceva.training.persistence.bo.TrainingDetails;
import org.springframework.orm.hibernate3.HibernateTemplate;

public class TrainingDetailService {

	private HibernateTemplate template;
	
	public void setTemplate(HibernateTemplate template) {
		this.template = template;
	}

	public List<TrainingDetails> getTrainings(Date startDate,Date endDate)
	{
		List<TrainingDetails> trainings = template.find("from TrainingDetails as schedule where schedule.beginDate between ? and ?", new Object[]{startDate,endDate});
		
		return trainings;
	}
	
	public void save(TrainingDetails schedule)
	{
		template.saveOrUpdate(schedule);
	}
	
	public List<TrainingDetails> getAll()
	{
		return template.find("from TrainingDetails as schedule");
	}
}
